package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class HandleOrder extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View view = new View(this);
		//리스너 우선순위1
		view.setOnTouchListener(new OnTouchListener() {			
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) { // 눌렀냐는 말임
					Toast.makeText(HandleOrder.this,
							"Listener : Touch Event Received!",
							Toast.LENGTH_LONG).show();
					return true;
				}
				return false;
			}
		});
		setContentView(view);
	}
	
	public class MyView extends View{
		public MyView(Context context) {
			super(context);
		}
		//뷰의 콜백메소드 우선순위 2
		public boolean onTouch(View v, MotionEvent event) {
			if (event.getAction() == MotionEvent.ACTION_DOWN) { // 눌렀냐는 말임
				Toast.makeText(HandleOrder.this,
						"View : Touch Event Received!",
						Toast.LENGTH_LONG).show();
				return true;
			}
			return false;
		}		
	}
	
	//액티비티의 콜백메소드 우선순위 3
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) { // 눌렀냐는 말임
			Toast.makeText(HandleOrder.this,
					"View : Touch Event Received!",
					Toast.LENGTH_LONG).show();
			return true;
		}
		return false;
	}
}
